package com.gdut.huayan.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.SignStyle;
import java.util.Locale;

import static java.time.temporal.ChronoField.*;
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;

public class TimeUtils {

    public static String getRTF3339(int afterTime){
        return LocalDateTime.now().plusMinutes(afterTime).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")) + "+08:00";
    }

    public static String getDateTime(){
        return LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
    }


    public static String getNumberTime(){
        return LocalDateTime.now().format(NUMBER_TIME);
    }

    public static final DateTimeFormatter NUMBER_TIME;
    static {
        NUMBER_TIME = new DateTimeFormatterBuilder()
                .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
                .appendValue(MONTH_OF_YEAR, 2)
                .appendValue(DAY_OF_MONTH, 2)
                .appendValue(HOUR_OF_DAY,2)
                .appendValue(MINUTE_OF_HOUR,2)
                .appendValue(SECOND_OF_MINUTE,2)
                .toFormatter(Locale.CHINESE);
    }

}
